﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Conference.Logic.Base;

namespace Conference.Logic.Schedule
{
    /// <summary>
    /// Class that represents a item of a session (moorning or afternoon)
    /// </summary>
    public class ItemSession: Item
    {
        #region Attributes

        private TimeSpan startTime; 
        #endregion

        #region Properties
        public TimeSpan StartTime
        {
            get 
            {
                return this.startTime; 
            }
            set
            {
                if (value != null)
                    this.startTime = value;
                else
                    throw new Exception("Start time is invalid value!");            
            }
        }

        public override ItemType Type
        {
            get
            {
                return base.Type;
            }
            set
            {
                if (value != ItemType.None)
                    base.Type = value;
                else
                    throw new Exception("Type is an invalid value!");
            }
        }

        #endregion

        #region Constructor
        /// <summary>
        /// Create a new item session
        /// </summary>
        /// <param name="description">Title</param>
        /// <param name="duration">Duration lenth</param>
        /// <param name="startTime">Start time</param>
        public ItemSession(string description, TimeSpan duration, TimeSpan startTime): 
            base(description, duration)
        {
            this.StartTime = startTime;
        }

        /// <summary>
        /// Create a new item session
        /// </summary>
        /// <param name="description">Title</param>
        /// <param name="type">Item type (default, lightning)</param>
        /// <param name="startTime">Start Time</param>
        public ItemSession(string description, ItemType type, TimeSpan startTime):
            base (description)
        {
            this.StartTime = startTime;
            this.Type = type;
            if (type == ItemType.Lightning)
                this.Duration = Parameter.Default.LenghtLightning;
        }

        #endregion       
    }
}
